package com.henu.art.controller;

import com.henu.art.service.UserService;
import com.henu.art.util.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/dashboard")
@Tag(name = "仪表盘面板")
public class DashboardController {
    @Resource
    private UserService userService;

    @RequestMapping(value = "/getUserCount", method = RequestMethod.GET)
    public Result<?> getUserCount(@RequestParam String status) {
        try {
            int count = userService.countByEmploymentStatus(status);
            return Result.ok(count);
        } catch (Exception e) {
            log.error("获取人数失败", e);
            return Result.error("获取人数失败");
        }
    }
}